﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JqueryNet.FormControl.FormHtmlControl
{
    public class JHtmlInputText : JHtmlControl
    {
        private System.Web.UI.HtmlControls.HtmlInputText htmlInputText;

        public JHtmlInputText(System.Web.UI.HtmlControls.HtmlInputText htmlInputText)
            : base(htmlInputText)
        {
            // TODO: Complete member initialization
            this.htmlInputText = htmlInputText;
        }


        public override void Val()
        {
            Value = htmlInputText.Value;
        }

        public override void Val(string value)
        {
            htmlInputText.Value = value;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "type":
                    Value = htmlInputText.Type;
                    return;
                case "maxlength":
                    Value = htmlInputText.MaxLength; return;
                case "size":
                    Value = htmlInputText.Size;
                    return;
                default: base.Attr(key);
                    return;
            }
        }

        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            switch (key.ToLower())
            {
                case "maxlength":
                    htmlInputText.MaxLength = b; return;
                case "size":
                    htmlInputText.Size = b;
                    return;
                default: base.Attr(key);
                    return;
            }
        }
    }
}
